package abstracttest;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.example.dao.SystemIconMapper;
import com.example.dao.SystemUserMapper;
import com.example.pojo.SystemIcon;
import com.example.pojo.SystemUser;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class AbstractMybatisPlus extends AbstractBase{
    @Autowired
    private SystemUserMapper systemUserMapper;

    @Autowired
    private SystemIconMapper systemIconMapper;

    @Test
    public void testInsert(){
        SystemUser systemUser=new SystemUser();
        systemUser.setUsername("test");
        Integer result=systemUserMapper.insert(systemUser);
        logger.info("result:"+result);
        logger.info("主键id:"+systemUser.getId());
    }

    @Test
    public void testSelectList(){
        List<SystemIcon> systemIcons=systemIconMapper.selectList(new EntityWrapper<SystemIcon>().orderBy("weight",true));
        for(SystemIcon systemIcon:systemIcons){
            logger.info("名称:"+systemIcon.getName()+",unicode:"+systemIcon.getUnicode());
        }
    }

    @Test
    public void testInsertSelect(){
        SystemUser systemUser=new SystemUser();
        systemUser.setUsername("test");
        systemUser.setPassword("123456");
        Integer result=systemUserMapper.insertAllColumn(systemUser);
        logger.info("result:"+result);
        logger.info("主键:"+systemUser.getId());
    }
}
